package com.neuedu.yyzx.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.neuedu.yyzx.common.CommonResult;
import com.neuedu.yyzx.entity.Role;
import com.neuedu.yyzx.service.IRoleService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 角色 前端控制器
 * </p>
 *
 * @author dya
 * @since 2021-05-10
 */
@RestController
@RequestMapping("//role")
public class RoleController {

    @Resource
    IRoleService roleService;

    @RequestMapping("/list")
    CommonResult list(Page page){
        QueryWrapper queryWrapper =new QueryWrapper();
        return CommonResult.success(roleService.page(page,queryWrapper));
    }

    @RequestMapping("/ids")
    CommonResult ids(){
        QueryWrapper queryWrapper=new QueryWrapper();
//        queryWrapper.select("id");
        queryWrapper.select("id","name");
        return  CommonResult.success(roleService.listMaps(queryWrapper));
    }

    @RequestMapping("/add")
    CommonResult add(Role role){
        return CommonResult.success(roleService.saveOrUpdate(role));

    }

    @RequestMapping("/getById")
    CommonResult getById(Integer id){

       return CommonResult.success(roleService.getById(id));
    }

    @RequestMapping("/del")
    CommonResult del(Integer id){
        return CommonResult.success(roleService.removeById(id));
    }



}
